package reflect;

import java.lang.reflect.Field;

//暴力反射对逻辑的破坏
public class ReflectDemo8 {
    public static void main(String[] args) throws Exception
    {
        String s1 = "abc";
        String s2 = "abc";

        System.out.println("s1="+s1);
        System.out.println("s2="+s2);
        Class cla = String.class;

        Field file = cla.getDeclaredField("value");//获取value属性
        file.setAccessible(true);//暴力反射
        file.set(s1, "def".toCharArray());//修改s1的值

        System.out.println("s1="+s1);
        System.out.println("s2="+s2);

        String s3 = "abc";
        System.out.println("s3="+s3);
    }



}
